package com.three.iot.channel.impl.aliyun;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.three.iot.channel.config.AliyunProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * @author luiz
 * @Title: AbstractChannelServiceAliyun
 * @ProjectName iot-server
 * @Description: TODO
 * @date 2019-05-08 10:17
 */
@Component
public abstract class AbstractChannelServiceAliyun {
    @Resource
    private  AliyunProperties aliyunProperties;

    protected DefaultAcsClient client = null;

    @PostConstruct
    private void initParam(){
        DefaultProfile.addEndpoint(aliyunProperties.getRegionId(), aliyunProperties.getProductId(), aliyunProperties.getDomainId());
        IClientProfile profile = DefaultProfile.getProfile(aliyunProperties.getRegionId(), aliyunProperties.getAccessKey(), aliyunProperties.getAccessSecret());
        //初始化SDK客户端
        client = new DefaultAcsClient(profile);
    }

}
